package pub.cleangao.mybatis.quick;

import pub.cleangao.mybatis.execution.DeleteExecution;
import pub.cleangao.mybatis.expression.Expressions;


/**
 * usage:
 * <p>Delete.from("user").where(Expression.lambda().eq("username", "clean")).done();;</p>
 */
public class Delete implements Quick<Integer> {

    private final DeleteExecution execution;

    private Delete(DeleteExecution execution) {
        this.execution = execution;
    }

    public static Delete from(String table) {
        return new Delete(DeleteExecution.startDelete(table));
    }

    public Delete where(Expressions expression) {
        execution.setWhereExpressionList(expression.getWhereExpressionList());
        return this;
    }

    public Integer done() throws Exception {
        return (Integer) execution.done();
    }


}
